#include<stdio.h>
void print_a(int a[],int n)
{
    int i=0;
    for(i=0;i<n;i++)
    {
        printf("%d ",a[i]);
        printf("\n");
    }
}
/*void shell_sort(int a[],int n)
{
    int i,j,inc,key;
    for(inc=n/2;inc>0;inc/=2)
    {
        for(i=inc;i<n;i++)
        {
            key=a[i];
            for(j=i;j>=inc&&a[j-inc]>key;j-=inc)
            {
                a[j]=a[j-inc];
            }
            a[j]=key;
        }
        print_a(a,n);
    }
}*/
void shell_sort(int a[],int n)
{
    int i,j,inc,key;
    for(inc=n/2;inc>0;inc/=2)
    {
        for(i=inc;i<n;i++)
        {
            key=a[i];
            for(j=i;j>=inc&&a[j-inc]>key;j-=inc)
            {
                a[j]=a[j-inc];
            }
            a[j]=key;
        }
    }
    print_a(a,n);
}
int main()
{
    int n,a[6000],i;
    scanf("%d",&n);
    for(i=0;i<n;i++)
    scanf("%d",&a[i]);
    shell_sort(a,n);
    return 0;
}